package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.business.business;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.business.business.BusinessService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 单位控制器
 */
@Action
@RequestMapping(value="business/business")
public class BusinessController extends BaseController {
    @Resource
    public BusinessService businessService;

    /**
     * 单位新增
     * @param
     * area	行政区划id
     * name	企业名称
     * enterpriseCode	企业代码
     * isHighRisk	是否高危：0 否 1 是
     * lon	经度
     * lat	纬度
     * addr	详细地址
     * fireRating	消防等级: 对应字典表：消防安全重点单位、消防安全一般单位、九小场所、 其它
     * unitProperty	单位性质:机关  团体 企业  事业  其它
     * oneResponPersonName	消防第一责任人
     * oneResponPersonPhone	消防第一责任人电话
     * safeResponPersonName	消防安全责任人
     * safeResponPersonPhone	消防安全责任人电话
     * safeManagePersonName	消防安全管理人
     * safeManagePersonPhone	消防安全管理人电话
     * industry	所属行业id
     * unitCategory	单位类别id
     * persons	"自定义管理人员：格式为[
     * {""经理"":[""张三"",""18660105856""]}
     * ]"
     * orgId	所属机构的id
     * @return
     */
    @At(value = "businessAdd", method = RequestMethod.POST, param = { "area"})
    public RespEntity businessAdd(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessAdd(jsonParam);
    }

    /**
     * 单位修改
     * @param
     * area	行政区划id
     * name	企业名称
     * enterpriseCode	企业代码
     * isHighRisk	是否高危：0 否 1 是
     * lon	经度
     * lat	纬度
     * addr	详细地址
     * fireRating	消防等级: 对应字典表：消防安全重点单位、消防安全一般单位、九小场所、 其它
     * unitProperty	单位性质:机关  团体 企业  事业  其它
     * oneResponPersonName	消防第一责任人
     * oneResponPersonPhone	消防第一责任人电话
     * safeResponPersonName	消防安全责任人
     * safeResponPersonPhone	消防安全责任人电话
     * safeManagePersonName	消防安全管理人
     * safeManagePersonPhone	消防安全管理人电话
     * industry	所属行业id
     * unitCategory	单位类别id
     * id	单位id
     * isDel	是否删除：1 是  0 没有
     * persons	"自定义管理人员：格式为[
     * {""经理"":[""张三"",""18660105856""]}
     * ]"
     * orgId	所属机构的id
     * @return
     */
    @At(value = "businessUpdate", method = RequestMethod.POST, param = { "area","id"})
    public RespEntity businessUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessUpdate(jsonParam);
    }

    /**
     * 单位删除
     * @param  jsonParam	单位的id
     * @return
     */
    @At(value = "businessDelete", method = RequestMethod.POST, param = { "businessId"})
    public RespEntity businessDelete(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessDelete(jsonParam);
    }

    /**
     * 单位列表
     * @param
     * page	第几页
     * limit	每页多少条
     * name	企业名称(模糊查询)
     * area	行政区划id(模糊查询)
     * ids	传过来的id数组，作为id范围查询
     * orgId	机构id
     * fireRating	消防等级: 对应字典表：消防安全重点单位、消防安全一般单位、九小场所、 其它
     * @return
     */
    @At(value = "businessListPage", method = RequestMethod.GET, param = { "page","limit" })
    public RespEntity businessListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessListPage(jsonParam);
    }

    /**
     * 单位详情
     * @param  id	单位的id
     * @return
     */
    @At(value = "detail", method = RequestMethod.GET)
    public RespEntity detail(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.detail(jsonParam);
    }

    /**
     * 行业列表
     * @param
     * @return
     */
    @At(value = "industryList", method = RequestMethod.GET)
    public RespEntity industryList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.industryList(jsonParam);
    }

    /**
     * 单位类别列表
     * @param
     * @return
     */
    @At(value = "unitCategoryList", method = RequestMethod.GET)
    public RespEntity unitCategoryList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.unitCategoryList(jsonParam);
    }

    /**
     * 行政区划列表
     * @param
     * @return
     */
    @At(value = "regionList", method = RequestMethod.GET)
    public RespEntity regionList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionList(jsonParam);
    }
    /**
     * 行政区划列表（后改的）
     * @param
     * @return
     */
    @At(value = "regionLists", method = RequestMethod.GET)
    public RespEntity regionLists(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionLists(jsonParam);
    }

    /**
     * 行政区划列表
     * @param
     * @return
     */
    @At(value = "regionAdd", method = RequestMethod.POST)
    public RespEntity regionAdd(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionAdd(jsonParam);
    }

    /**
     * 行政区划删除
     * @param
     * @return
     */
    @At(value = "regionDel", method = RequestMethod.POST)
    public RespEntity regionDel(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionDel(jsonParam);
    }

    /**
     * 行政区划编辑
     * @param
     * @return
     */
    @At(value = "regionUpdate", method = RequestMethod.POST)
    public RespEntity regionUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionUpdate(jsonParam);
    }
    /**
     * 行政区划详情
     * @param
     * @return
     */
    @At(value = "regionDetail", method = RequestMethod.GET)
    public RespEntity regionDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.regionDetail(jsonParam);
    }
    /**
     * 字典组查询
     * @param  groupname	字典组
     * @return
     */
    @At(value = "dictList", method = RequestMethod.GET, param = { "groupname" })
    public RespEntity dictList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.dictList(jsonParam);
    }

    /**
     * 单位不分页列表
     * @param
     * name	企业名称(模糊查询)
     * area	行政区划id(模糊查询)
     * ids	传过来的id数组，作为id范围查询
     * orgId	机构id
     * fireRating	消防等级: 对应字典表：消防安全重点单位、消防安全一般单位、九小场所、 其它
     * @return
     */
    @At(value = "businessList", method = RequestMethod.GET)
    public RespEntity businessList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessList(jsonParam);
    }
    /**
     * 根据行政区划获取单位列表
     * @param
     * @return
     */
    @At(value = "getBusinessLists", method = RequestMethod.GET)
    public RespEntity getBusinessLists(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessLists(jsonParam);
    }
    /**
     * 上传
     * @param
     * @return
     */
    @At(value = "upload", method = RequestMethod.POST)
    public RespEntity upload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws IOException{
        return businessService.upload(file,request);
    }

    /**
     * 下载
     * @param
     * @return
     */
    @At(value = "download", method = RequestMethod.GET)
    public ResponseEntity<byte[]> download(@RequestParam("filepath") String filepath) throws Exception {
        return businessService.download(filepath,request);
    }

    /**
     * 根据消防等级分类统计机构单位数目
     * @param  orgId	机构id
     * @return
     */
    @At(value = "businessCount", method = RequestMethod.GET, param = { "orgId" })
    public RespEntity businessCount(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.businessCount(jsonParam);
    }

    /**
     * 应知应会列表
     * @param
     * @return
     */
    @At(value = "shouldknowList", method = RequestMethod.GET)
    public RespEntity shouldknowList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.shouldknowList(jsonParam);
    }

    /**
     * 获取所有上级行政区划接口
     * @param
     * bottomArea    最下层的行政区划	是
     * @return
     */
    @At(value = "getAllArea", method = RequestMethod.GET, param = { "bottomArea" })
    public RespEntity getAllArea(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getAllArea(jsonParam);
    }

    /**
     * 消防主管部门列表
     * @param
     * @return
     */
    @At(value = "fireDepartmentTreeList", method = RequestMethod.GET)
    public RespEntity fireDepartmentTreeList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.fireDepartmentTreeList(jsonParam);
    }

    /**
     * 行业主管部门
     * @param
     * @return
     */
    @At(value = "industryAuthoritiesTreeList", method = RequestMethod.GET)
    public RespEntity industryAuthoritiesTreeList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.industryAuthoritiesTreeList(jsonParam);
    }

    /**
     * 测试https
     * @param
     * @return
     */
    @At(value = "test", method = RequestMethod.GET)
    public RespEntity test(@RequestBody(required = false) JSONObject jsonParam) {
        return RespEntity.success(111);
    }

    /**
     * 删除redis里边的key
     * @param jsonParam
     * @return
     */
    @At(value = "removeKey", method = RequestMethod.POST)
    public RespEntity removeKey(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.removeKey(jsonParam);
    }
    /**
     * 续费
     */
    @At(value = "renew", method = RequestMethod.POST)
    public RespEntity renew(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.renew(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 查看单位服务是否到期
     * @Date Created in 14:18 2022/6/30
     * @Param [jsonParam]
     */

    @At(value = "checkBusinessExpire", method = RequestMethod.GET)
    public RespEntity checkBusinessExpire(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.checkBusinessExpire(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 设置仪表盘数据
     * @Date Created in 14:18 2022/6/30
     * @Param [jsonParam]
     */
    @At(value = "setPressureGaugeValue", method = RequestMethod.POST)
    public RespEntity setPressureGaugeValue(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.setPressureGaugeValue(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 获取仪表盘数据
     * @Date Created in 14:18 2022/6/30
     * @Param [jsonParam]
     */

    @At(value = "getPressureGaugeValue", method = RequestMethod.GET)
    public RespEntity getPressureGaugeValue(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getPressureGaugeValue(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 更新企业NFC_ID
     * @Date Created in 14:18 2022/6/30
     * @Param [jsonParam]
     */
    @At(value = "updateBusinessNfcID", method = RequestMethod.POST,param = {"id","nfcId"})
    public RespEntity updateBusinessNfcID(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.updateBusinessNfcID(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 单位统计(根据单位类别)
     * @Date Created in 17:18 2024/4/27
     * @Param [jsonParam]
     */

    @At(value = "getBusinessTypeCountList", method = RequestMethod.GET)
    public RespEntity getBusinessTypeCountList(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.getBusinessTypeCountList(jsonParam);
    }


    // ---------应急物资----------

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 物资新增或者更新
     */
    @PostMapping("addOrUpdateMaterials")
    public RespEntity addOrUpdateMaterials(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.addOrUpdateMaterials(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 获取物资信息列表
     */
    @GetMapping("getMaterialsList")
    public RespEntity getMaterialsList(@RequestBody(required = false)JSONObject jsonObject) {
        return businessService.getMaterialsList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除物资信息
     */
    @PostMapping("delMaterials")
    public RespEntity delMaterials(@RequestBody(required = false)JSONObject jsonObject) {
        return businessService.delMaterials(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取物资信息
     */
    @GetMapping("getMaterialsInfo")
    public RespEntity getMaterialsInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getMaterialsInfo(jsonObject);
    }


    // ---------应急场所----------

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 应急场所新增或者更新
     */
    @PostMapping("addOrUpdatePlace")
    public RespEntity addOrUpdatePlace(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.addOrUpdatePlace(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 应急场所物资信息列表
     */
    @GetMapping("getPlaceList")
    public RespEntity getPlaceList(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getPlaceList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取应急场所
     */
    @GetMapping("getPlaceInfo")
    public RespEntity getPlaceInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getPlaceInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除应急场所信息
     */
    @PostMapping("delPlace")
    public RespEntity delPlace(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.delPlace(jsonObject);
    }


    // ---------应急专家----------

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 应急专家新增或者更新
     */
    @PostMapping("addOrUpdateProfessor")
    public RespEntity addOrUpdateProfessor(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.addOrUpdateProfessor(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 应急专家信息列表
     */
    @GetMapping("getProfessorList")
    public RespEntity getProfessorList(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getProfessorList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取应急专家
     */
    @GetMapping("getProfessorInfo")
    public RespEntity getProfessorInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getProfessorInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除应急专家
     */
    @PostMapping("delProfessor")
    public RespEntity delProfessor(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.delProfessor(jsonObject);
    }


    // ---------应急队伍----------

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 应急团队新增或者更新
     */
    @PostMapping("addOrUpdateTeam")
    public RespEntity addOrUpdateTeam(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.addOrUpdateTeam(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 应急团队信息列表
     */
    @GetMapping("getTeamList")
    public RespEntity getTeamList(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getTeamList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取应急团队
     */
    @GetMapping("getTeamInfo")
    public RespEntity getTeamInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getTeamInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除应急团队
     */
    @PostMapping("delTeam")
    public RespEntity delTeam(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.delTeam(jsonObject);
    }


    // -------微型消防站-----
    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 微型消防站新增或者更新
     */
    @PostMapping("addOrUpdateFirestation")
    public RespEntity addOrUpdateFirestation(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.addOrUpdateFirestation(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 微型消防站信息列表
     */
    @GetMapping("getFirestationList")
    public RespEntity getFirestationList(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getFirestationList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取微型消防站
     */
    @GetMapping("getFirestationInfo")
    public RespEntity getFirestationInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getFirestationInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除微型消防站
     */
    @PostMapping("delFirestation")
    public RespEntity delFirestation(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.delFirestation(jsonObject);
    }


    /**
     * Author: xulumin
     * @param jsonObject
     * Description: 应急保障情况信息
     */
    @GetMapping("getEmgInfo")
    public RespEntity getEmgInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getEmgInfo(jsonObject);
    }


    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 证书新增或者更新
     */
    @PostMapping("addOrUpdateCertificate")
    public RespEntity addOrUpdateCertificate(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.addOrUpdateCertificate(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 获取证书信息列表
     */
    @GetMapping("getCertificateList")
    public RespEntity getCertificateList(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getCertificateList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取证书信息
     */
    @GetMapping("getCertificateInfo")
    public RespEntity getCertificateInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.getCertificateInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除证书信息
     */
    @PostMapping("delCertificate")
    public RespEntity delCertificate(@RequestBody(required = false) JSONObject jsonObject) {
        return businessService.delCertificate(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 获取区域下证书信息列表
     */
    @GetMapping("getCertificateAreaList")
    public RespEntity getCertificateAreaList(@RequestBody(required = false)JSONObject jsonObject) {
        return businessService.getCertificateAreaList(jsonObject);
    }


    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 区域概况查询
     */
    @GetMapping("getRegionalInfo")
    public RespEntity getRegionalInfo(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.getRegionalInfo(jsonObject);
    }


    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 辖区行业分布情况
     */
    @GetMapping("getIndustryInfo")
    public RespEntity getIndustryInfo(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.getIndustryInfo(jsonObject);
    }


    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 辖区预警提醒
     */
    @GetMapping("getAreaWarning")
    public RespEntity getAreaWarning(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return businessService.getAreaWarning(jsonObject);
    }

    /**
     * @Author: xulumin
     * @ClassName: DeviceSwitchController
     * @Date: Created in 9:23 2024.03.26
     * @Description: 一企一档大屏查询设备报警
     */
    @GetMapping("getAreaDeviceInfo")
    public RespEntity getAreaDeviceInfo(@RequestBody(required = false)JSONObject jsonObject) {
        return businessService.getAreaDeviceInfo(jsonObject);
    }


    /**
     * @Author YangYu
     * @Description 施工单位分页列表
     * @Date Created in 11:39 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "constructionUnitListPage", method = RequestMethod.GET)
    public RespEntity constructionUnitListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.constructionUnitListPage(jsonParam);
    }


    /**
     * @Author YangYu
     * @Description 施工单位新增、编辑
     * @Date Created in 11:39 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "constructionUnitAddOrUpdate", method = RequestMethod.POST)
    public RespEntity constructionUnitAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.constructionUnitAddOrUpdate(jsonParam);
    }


    /**
     * @Author YangYu
     * @Description 施工单位详情
     * @Date Created in 11:39 2024/7/11
     * @Param [jsonParam]
     */

    @At(value = "constructionUnitDetails", method = RequestMethod.GET)
    public RespEntity constructionUnitDetails(@RequestBody(required = false) JSONObject jsonParam) {
        return businessService.constructionUnitDetails(jsonParam);
    }

}
